package com.yaozheng.vocationaltraining.view;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.widget.ExamProgressButtonStatusView;

@EViewGroup(R.layout.view_exam_progress_status)
public class ExamProgressStatusView extends LinearLayout {
    /**
     * 状态 大于等于0 分数 -1 未考 -2 考试中
     */
    private int status;
    @ViewById
    ImageView paperStatusImage;
    @ViewById
    View paperStatusLayout;
    @ViewById
    TextView paperStatusBut, paperStatusTypeExplanationText;
    @ViewById
    ExamProgressButtonStatusView examProgressButtonStatusView;


    public ExamProgressStatusView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public ExamProgressStatusView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    public ExamProgressButtonStatusView getExamProgressButtonStatusView() {
        return examProgressButtonStatusView;
    }

    @AfterViews
    public void initView() {
        setStatus(-1);
    }

    /**
     * @param status 状态 大于等于0 分数 -1 未考 -2 考试中 -3暂停
     */
    public void setStatus(int status) {
        this.status = status;
        if (status >= 0) {
            paperStatusImage.setVisibility(View.GONE);
            paperStatusLayout.setVisibility(View.VISIBLE);
            paperStatusBut.setText(String.valueOf(status));
            examProgressButtonStatusView.setCurrProgress(status);
        } else {
            paperStatusLayout.setVisibility(View.GONE);
            paperStatusImage.setVisibility(View.VISIBLE);
            examProgressButtonStatusView.setCurrProgress(100);
            if (status == -1) {
                paperStatusImage.setEnabled(true);
                paperStatusImage.setSelected(true);
            } else if (status == -2) {
                paperStatusImage.setEnabled(true);
                paperStatusImage.setSelected(false);
            } else {
                paperStatusImage.setEnabled(false);
                paperStatusImage.setSelected(true);
            }
        }
    }

    /**
     * 设置分 %
     *
     * @param paperStatusTypeExplanationStr
     */
    public void setPaperStatusTypeExplanationTextValue(String paperStatusTypeExplanationStr) {
        paperStatusTypeExplanationText.setText(paperStatusTypeExplanationStr);
    }

    /**
     * 设置字体颜色白色
     */
    public void setTextColorWhite() {
        paperStatusBut.setTextColor(Color.WHITE);

        paperStatusTypeExplanationText.setTextColor(Color.WHITE);
    }

    public void disable() {
        paperStatusImage.setImageResource(R.drawable.icon_no_start_22);
        examProgressButtonStatusView.setAllPaintColor(Color.parseColor("#E5E5E5"));
    }

    public void enable() {
        paperStatusImage.setImageResource(R.drawable.paper_status_image_bg_selected);
        examProgressButtonStatusView.setDefaultAllPaintColor();
    }


}
